package com.xiaofei.demo.concurrent_beauty.ch1_basic;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class ThreadExample {

    public String uppperCase(){
        return "ACS";
    }
    public static class myThread extends Thread{
        @Override
        public void run(){
            System.out.println("I am a child thread");
        }
    }
    public static class RunabbleClass implements Runnable{

        @Override
        public void run() {
            // TODO Auto-generated method stub
            System.out.println("I am a runnable thread");
        }
        
    }

    public static class CallerTask implements Callable{

        @Override
        public Object call() throws Exception {
            // TODO Auto-generated method stub
            return "Hello";
        }   
    }
    public static void main(String[] args) {
        Thread childThread = new myThread();
        childThread.start();
        Runnable runabbleThread = new RunabbleClass();
        runabbleThread.run();
        new Thread(runabbleThread).start();
        new Thread(runabbleThread).start();
        FutureTask<String> futureTask = new FutureTask<>(new CallerTask());
        new Thread(futureTask).start();

        try {
            String callResult = futureTask.get();
            System.out.println(callResult);
        } catch (InterruptedException | ExecutionException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
    }
}
